package com.qiuyang.controller;

import com.qiuyang.pojo.Comment;
import com.qiuyang.service.show.ShowCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class ShowCommentController {

    @Autowired
    private ShowCommentService showCommentService;

    @ResponseBody
    @RequestMapping("/insertComment")
    public Comment insertComment(Comment comment){
        showCommentService.inserComment(comment);
        return showCommentService.findComment(comment.getId());
    }


    @RequestMapping("/queryComment/{id}")
    @ResponseBody
    public List<Comment> queryComment(@PathVariable Long id){
        System.out.println(id);
        System.out.println(showCommentService.findCommentByBid(id).toString());
        return showCommentService.findCommentByBid(id);
    }

}
